<?php
require('./FPDF/fpdf.php');
require_once '../inc/configuration.php';
require_once '../inc/connexion_db.php';
require_once '../inc/fonctions_sql.php';

$id = isset($_GET ['id'])? $_GET ['id'] : ""; 
$id_entreprise = isset($_GET ['id_entreprise'])? $_GET ['id_entreprise'] : ""; 


$query="SELECT *, entreprises.raison_sociale FROM contacts, entreprises WHERE  contacts.id=".$id." AND contacts.id_entreprise=entreprises.id";
$resultat=mysqli_query($connexion_bd,$query);
$row=  mysqli_fetch_assoc($resultat);

$titre = 'Carte de visite';
$pdf = new FPDF('L','mm',array(85,54));
$pdf ->SetLeftMargin(3);
$pdf ->SetRightMargin(3);
$pdf ->SetTopMargin(3);
$pdf ->SetAutoPageBreak(0,3);
$pdf->AddPage();


$pdf->Image('./images/fond.jpg', 0,0,85);
//$pdf->Image('./FPDF/test.jpg', 3,3,27,24);
//$pdf->Image('../contacts/photos/martin.jpg', 3,3,27,24);
$pdf->Image('../contacts/photos/'.$row['photo'], 3,3,27,24);

$pdf->SetFont('Helvetica','',12);
$pdf->SetXY(32,5);
$pdf->Write(0,$row['raison_sociale']);
$pdf->SetFont('Helvetica','',9);
$pdf->SetXY(32,14);
$pdf->Text(33,14,$row['observations']);
$pdf->SetFont('Helvetica','',9);
$pdf->SetXY(32,21);
$pdf->Text(33,21,$row['adresse']);
$pdf->SetFont('Helvetica','',9);
//$pdf->SetXY(32,25);
//$pdf->Write(0,"78000 paris");


$pdf->SetFont('Helvetica','',8);
$pdf->SetXY(3,33);
$pdf->Write(0,'COMMERCIAL');
$pdf->SetFont('Helvetica','',11);
$pdf->SetXY(3,36);
$pdf->Write(5,$row['nom']." ".$row['prenom']);
$pdf->SetFont('Helvetica','',8);
$pdf->SetXY(3,40);
$pdf->Write(8,$row['email']);
$pdf->SetFont('Helvetica','',8);
$pdf->SetXY(3,45);
$pdf->Write(10,'site web / autre');

$pdf->SetFont('Helvetica','',10);
$pdf->SetXY(53,28);
$pdf->Write(10,$row['telephone']);

$pdf->Output();


?>